# -*- coding: utf-8 -*-
import cgi
import datetime
import wsgiref.handlers

from google.appengine.ext import db

class Role( object ):
    def __init__(self, permissions = set()):
        self.permissions = set(permissions)

    def hasPermission(self, permission):
        return permission in self.permissions

    def showAllLink(self):
        return "/role/showAll"

roles = {
    'admin': Role(['admin', 'usersNew', 'usersEdit', 'usersDelete', 'usersShow', 'tiNew', 'tiEdit', 'tiDelete', 'tiShow', 'soNew', 'soEdit', 'soDelete', 'soShow', 'mfNew', 'mfEdit', 'mfDelete', 'mfShow', 'mpShow', 'mpTemp', 'ctShow', 'ctEdit', 'ctDelete', 'ctNew', 'MPTUploadForm']),
    'shipper': Role(['usersNew', 'usersEdit', 'usersDelete', 'usersShow', 'tiNew', 'tiEdit', 'tiDelete', 'tiShow', 'soNew', 'soEdit', 'soDelete', 'soShow', 'mfNew', 'mfEdit', 'mfDelete', 'mfShow', 'mpShow', 'mpTemp', 'ctShow']),
    'manager': Role(['usersShow', 'tiShow', 'soShow', 'mfShow', 'mpShow', 'mpTemp', 'ctShow']),
    'driver': Role(['tiNew', 'tiEdit', 'tiShow']),
    'user': Role(['tiNew', 'tiShow', 'soNew', 'soEdit', 'soShow', 'usersNew', 'usersEdit']),
    'pedestrian': Role(['usersNew'])
    }
